package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {
    /**
     * 根据菜品ID查询关联的套餐
     * @param ids
     * @return
     */
    List<Long> getSetmealIdsByDishIds(List<Long> ids);

    /**
     * 批量插入菜品
     * @param setmealDishes
     */
    void insertBatch(List<SetmealDish> setmealDishes);

    /**
     * 获取菜品的状态
     * @param dishId
     * @return
     */
    @Select("select status from dish where id = #{dishId}")
    Object getStatus(Long dishId);

    /**
     * 根据套餐的分类ID查询分类名称
     * @param categoryId
     * @return
     */
    @Select("select name from dish where category_id = #{categoryId}")
    String getName(Long categoryId);

    /**
     * 根据套餐ID查询关联的菜品
     * @param setmealId
     * @return
     */
    @Select("select dish_id from setmeal_dish where setmeal_id = #{setmealId}")
    List<Long> getDishId(Long setmealId);

    /**
     * 根据关联的菜品ID查询菜品
     * @param setmealId
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{setmealId}")
    List<SetmealDish> getSetmealDish(Long setmealId);

    /**
     * 根据套餐ID删除中间表数据
     * @param setmealId
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void delete(Long setmealId);
}
